<template>
    <div class="data-member-center">
        <section class="app-main">
            <div class="app-block-first">
                <!--<div class="block-first-content">-->
                    <!--<dl class="count-list">-->
                        <!--<dd class="count-item">接单数<span class="count">10</span>环比昨日<span-->
                                <!--class="count-increase iconfont icon-shuzhixiajiang"></span>20-->
                        <!--</dd>-->
                        <!--<dd class="count-item">接单数<span class="count">5</span>环比昨日<span-->
                                <!--class="count-reduce iconfont icon-shuzhixiajiang"></span>20-->
                        <!--</dd>-->
                        <!--<dd class="count-item">接单数<span class="count">10</span>环比昨日<span-->
                                <!--class="count-increase iconfont icon-shuzhixiajiang"></span>20-->
                        <!--</dd>-->
                    <!--</dl>-->
                <!--</div>-->
              <dl class="app-block-count count-list">
                <dd class="block-item"@click="handleOrderList('4','today')">
                  <span class="item-title">已完成</span>
                  <span class="item-count">
                    {{res.todayFinishCount}}
                    <dl class="item-count-details">
                      <dd class="tips">今日单{{(res.todayAddCount)-(res.todayUnFinishCount)}}</dd>
                      <dd class="tips">过往单{{(res.todayFinishCount)-((res.todayAddCount)-(res.todayUnFinishCount))}}</dd>
                    </dl>
                  </span>
                  <div class="count-item">
                    环比昨日<span :class="[res.dayFinishCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.dayFinishCountDiff)}}
                  </div>
                </dd>
                <dd class="block-item">
                  <span class="item-title">接单数</span>
                  <span class="item-count">{{res.todayAddCount}}</span>
                  <div class="count-item">
                    环比昨日<span :class="[res.dayCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.dayCountDiff)}}
                  </div>
                </dd>
                <dd class="block-item" @click="handleOrderList('2','today')">
                  <span class="item-title">未完成</span>
                  <span class="item-count">{{res.todayUnFinishCount}}</span>
                  <div class="count-item">
                    环比昨日<span :class="[res.dayUnFinishCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.dayUnFinishCountDiff)}}
                  </div>
                </dd>
              </dl>
                <div class="block-first-title">今日情况</div>
            </div>
            <div class="app-block-third">
                <div class="block-third-content block-third-week">
                    <div class="content">
                        <span class="item-title">本周</span>
                        <dl class="count-list">
                            <dd class="count-item"><span class="count-addon">接单数</span><span class="count">{{res.weekAddCount}}</span>环比上周<span :class="[res.weekCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.weekCountDiff)}}
                            </dd>
                            <dd class="count-item"><span class="count-addon">已完成</span><span class="count">{{res.weekFinishCount}}</span>环比上周<span :class="[res.weekFinishCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.weekFinishCountDiff)}}
                            </dd>
                            <dd class="count-item"><span class="count-addon">未完成</span><span class="count">{{res.weekUnFinishCount}}</span>环比上周<span :class="[res.weekUnFinishCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.weekUnFinishCountDiff)}}
                            </dd>
                        </dl>
                    </div>
                </div>
                <div class="block-third-content block-third-month">

                    <div class="content">
                        <span class="item-title">本月</span>
                      <dl class="count-list">
                        <dd class="count-item"><span class="count-addon">接单数</span><span class="count">{{res.monthAddCount}}</span>环比上月<span :class="[res.monthCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.monthCountDiff)}}
                        </dd>
                        <dd class="count-item"><span class="count-addon">已完成</span><span class="count">{{res.monthFinishCount}}</span>环比上月<span :class="[res.monthFinishCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.monthFinishCountDiff)}}
                        </dd>
                        <dd class="count-item"><span class="count-addon">未完成</span><span class="count">{{res.monthUnFinishCount}}</span>环比上月<span :class="[res.monthUnFinishCountDiff>=0 ? 'count-increase':'count-reduce']" class="iconfont icon-shuzhixiajiang"></span>{{Math.abs(res.monthUnFinishCountDiff)}}
                        </dd>
                      </dl>
                    </div>
                </div>
            </div>
          <dl class="app-block-second app-block-count">
            <dd class="block-item">
              <span class="item-title">累计已完成</span>
              <span class="item-count">{{res.finishCount}}</span>
            </dd>
            <dd class="block-item">
              <span class="item-title">累计接单数</span>
              <span class="item-count">{{res.totalCount}}</span>
            </dd>
            <dd class="block-item" @click="handleOrderList('2','all')">
              <span class="item-title">累计未完成</span>
              <span class="item-count">{{(res.totalCount)-(res.finishCount)}}</span>
            </dd>
          </dl>

          <template v-if="userRole=='storeSA'">
            <div class="app-data-money" @click="handleMoneyDetails">
              <mt-cell class="action-money-details" title="收入详情" is-link></mt-cell>
              <div class="money-title">累计销售额</div>
              <div class="money-count">￥{{orderCount.num}}</div>
              <div class="money-tips">
                <span class="tips-item">今日收入￥{{orderCount.dayAmount}}</span>
                <span class="tips-item">本周收入￥{{orderCount.weekAmount}}</span>
              </div>
            </div>

          </template>
          <template v-if='shopKeeper==1'>
            <div class="other-action">
              <mt-cell title="团队统计" is-link @click.native="handleStaffDetails('staff')"></mt-cell>
            </div>
            </template>
          <template v-if="userRole=='dispatcher'">
            <div class="other-action">
              <mt-cell title="门店统计" is-link @click.native="handleStaffDetails('store')"></mt-cell>
            </div>
          </template>

        </section>
    </div>
</template>

<script>


    import {Header, Cell, Toast} from 'mint-ui';
    export default {
        data () {
            return {
              userRole:'',
              shopKeeper:'',
              test:-1,
              orderCount:{
                num:'',
                dayAmount:'',
                weekAmount:'',
              },
              res:{},
            }
        },
        created(){
            this.getStoreData();
        },
        methods: {
            getStoreData() {

              /**获取角色**/
              var params = new URLSearchParams();
              this.$axios({
                method: 'post',
                url:'gp/users/getUserInfo',
                data:params
              }).then((res)=>{
                console.log(res)
              if(res.data.statusCode==200){
                this.shopKeeper=res.data.object.shopKeeper;
                console.log(res,123456);

                if(res.data.object.roleList.indexOf('dispatcher')!=-1){
                  this.userRole='dispatcher'
                }else if(res.data.object.roleList.indexOf('storeSA')!=-1){
                  this.userRole='storeSA'
                }

                console.log(this.userRole,this.shopKeeper,1111)
              }else{
                Toast({
                  message: res.data.message,
                  position: 'middle',
                  duration:800
                });
              }

            })

              /**获取金额统计**/
              this.$axios({
                method: 'post',
                url:'gp/dataStatics/getStoreData',
              }).then((res)=>{
                console.log(res,123)
              this.orderCount.num=res.data.object.allAccount;
              this.orderCount.dayAmount=res.data.object.dayAmount;
              this.orderCount.weekAmount=res.data.object.weekAmount;
            });

              /**获取统计数据**/
              var params = new URLSearchParams();
              this.$axios({
                method: 'post',
                url:'gp/declaration/storeStats',
                data:params
              }).then((res)=>{
                if(res.data.statusCode==200){
                console.log(res,111)
                this.res=res.data.object
              }else{
                Toast({
                  message: res.data.message,
                  position: 'middle',
                  duration:800
                });
              }
            })
            },
          handleStaffDetails(type){
            if(type=='staff'){
              this.$router.push({path:'/data-staff'})
            }else if(type=='store'){
              this.$router.push({path:'/data-store-statistics'})
            }
          },
          handleMoneyDetails(){
            this.$router.push({path:'/oil-store-data'})
          },
          handleOrderList(stateId,date){
            this.$router.push({path:'/data-push-list',query: {stateId:stateId,date:date}})
          },
        }
    }
</script>
<style src="../../../static/member-center.css"></style>
<style>
    /*@import '../../../static/mebase.css'*/
</style>
